package cn.wetcland.urban.admin.controller;

import cn.wetcland.urban.admin.dto.AddressUpdateDTO;
import cn.wetcland.urban.admin.service.UtCustomerAddressService;
import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.generator.domain.UtCustomerAddress;
import cn.wetcland.urban.generator.dto.BaseConditionSearchDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/address")
public class AddressController {
    
    @Resource
    private UtCustomerAddressService customerAddressService;

    @GetMapping("/addressList")
    public AjaxResponse addressList(BaseConditionSearchDTO searchDTO) {
        Page<UtCustomerAddress> addressPage = customerAddressService.addressList(searchDTO);
        return AjaxResponse.success(addressPage);
    }

    @PutMapping("/addressUpdate")
    public AjaxResponse addressUpdate(@RequestBody AddressUpdateDTO updateDTO) {
        customerAddressService.addressUpdate(updateDTO);
        return AjaxResponse.success();
    }

    @DeleteMapping("/addressDelete/{addressId}")
    public AjaxResponse addressDelete(@PathVariable Long addressId) {
        customerAddressService.addressDelete(addressId);
        return AjaxResponse.success();
    }
    
}
